Feature/929/js custom question pages#1193
Conversation
…m on the Question Customization pages but have them be disabled
| givenName: 'John', | ||
| surName: 'Doe', | ||
| affiliation: { name: 'Test Institution', uri: 'test-uri' }, | ||
| affiliation: { name: 'Test Institution', uri: 'test-uri', displayName: 'Test Institution' }, |
There was a problem hiding this comment.
I added the affiliationName.displayName to the MeQuery for the QuestionPreview so that we could be explicit about which Org added the guidance, therefore I was required to add it to some unit test mocks.
| isOptionsType, | ||
| getOverrides, | ||
| } from './hooks/useEditQuestion'; | ||
| } from '@/app/hooks/useEditQuestion'; |
There was a problem hiding this comment.
Moved the useEditQuestion to a shared location since the new Custom Question pages use it too
| Text | ||
| } from "react-aria-components"; | ||
|
|
||
|
|
There was a problem hiding this comment.
This page was updated to pass in new props to the shared QuestionAdd, because it is now shared with the Custom Question pages
| // TODO: Need to implement a shared loading component | ||
| if (step === null) { | ||
| return <div>...{Global('messaging.loading')}</div> | ||
| return <Loading />; |
There was a problem hiding this comment.
Add Loading component here
| <Button | ||
| type="submit" | ||
| aria-disabled={isSubmitting} | ||
| isDisabled={isSubmitting} |
There was a problem hiding this comment.
Adding disabling of Submit button when submit request is still active
| 'use client'; | ||
|
|
||
| import React, { useEffect, useRef, useState } from 'react'; | ||
| import Link from 'next/link'; |
There was a problem hiding this comment.
Switched to using next/link because it's much faster than using React Aria Component's
There was a problem hiding this comment.
Is that something we'll want to do site wide? If so, make sure you create a ticket so we don't lose track!
Seems like a perfect task for the Reeves team at some point
| @@ -0,0 +1,6 @@ | |||
| import Loading from '@/components/Loading'; | |||
There was a problem hiding this comment.
Added this new component just in case, so page loads can fall back to this if it takes longer than 300ms
| onChange?: (value: string) => void; | ||
| isRequired?: boolean; | ||
| isRequiredVisualOnly?: boolean; | ||
| isDisabled?: boolean; |
There was a problem hiding this comment.
For Question Customization pages, all form fields will be disabled in the page, so I updated all form fields with the isDisabled prop
| questionName, | ||
| questionJSON, | ||
| sectionId }: | ||
| sectionId, |
There was a problem hiding this comment.
New props were added so that we can more easily share this component between BASE and CUSTOM questions
| interface QuestionPreviewProps extends React.HTMLAttributes<HTMLDivElement> { | ||
| buttonLabel?: string, | ||
| previewDisabled?: boolean, | ||
| onOpenChange?: (isOpen: boolean) => void, |
There was a problem hiding this comment.
Just passing an onOpenChange callback that helps re-render the fields in the previous page when the Preview modal is closed.
| 'use client'; | ||
|
|
||
| import React, { useEffect, useRef, useState } from 'react'; | ||
| import Link from 'next/link'; |
There was a problem hiding this comment.
Is that something we'll want to do site wide? If so, make sure you create a ticket so we don't lose track!
Seems like a perfect task for the Reeves team at some point
| @@ -0,0 +1,6 @@ | |||
| import Loading from '@/components/Loading'; | |||
Description
CustomQuestionEditpageQuestionCustomizepageCustomQuestionNewpageAddCustomQuestion,UpdateCustomQuestion,RemoveCustomQuestion,AddQuestionCustomization,UpdateQuestionCustomization,RemoveQuestionCustomizationmutationsCustomQuestionandQuestionCustomizationByVersionedQuestionmutationsutils/routes.tsaddQuestionMutationout ofQuestionViewso thatQuestionViewcan be shared for bothBASEandCUSTOMquestionsQuestionTypeSelectPageto include theaddQuestionMutationandgetDisplayOrderand pass those toQuestionAddLoadingcomponent inTemplateCreatePagefetchPolicyofcache-and-networktoTemplateCustomiationOverviewquery so that we get updated data when user returns from editing section or questionisDisabledprop so that users customizing existing questions can see a disabled version of the form fieldsQuestionAddto accept more props and be more flexible for shared use with Custom QuestionsQuestionViewto accept more props likeorgGuidanceso it can be shared with Custom QuestionsFixes # (929)
Type of change
How Has This Been Tested?
Manually tested with backend PR, CDLUC3/dmptool-apollo-server#636, and added unit tests
Checklist:
*Note: backend PR that goes with this branch: Updates for Custom Questions dmptool-apollo-server#636
Important Note:
Please make sure to do a careful merge of development branch into yours, to make sure you aren't reverting or effecting any previous commits to the development branch.
Screenshots
Custom Questions are given different styles
Question Customization of a
BASEText area questionCustomization of an existing Radio Button question. Note that the form fields are disabled
When Question Customization is going to be deleted, a confirmation modal appears